package uniandes.cupi2.musiteka.servidor.interfaz;

import javax.swing.JPanel;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.io.IOException;

import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JComboBox;

import uniandes.cupi2.musiteka.servidor.mundo.IMusiteka;
import uniandes.cupi2.musiteka.servidor.mundo.musiteka1.Musiteka;

public class DialogoAgregarCancion extends JDialog
{

    private static final long serialVersionUID = 1L;
    private JPanel jContentPane = null;
    private JLabel jLabelNombreCancion = null;
    private JTextField jTextFieldNombreCancion = null;
    private JLabel jLabelGeneroCancion = null;
    private JTextField jTextFieldGeneroCancion = null;
    private JLabel jLabelDuracionCancion = null;
    private JLabel jLabelArtistaCancion = null;
    private JTextField jTextFieldDuracionCancion = null;
    private JTextField jTextFieldArtistaCancion = null;
    private JButton jButtonAgregarCancion = null;
    private JButton jButtonCancelar = null;
	private JComboBox jComboBoxGeneroCancion = null;
	public Musiteka mundo = null;
    public DialogoAgregarCancion(IMusiteka nMundo) 
    {
    	mundo= (Musiteka) nMundo;
    	super.setVisible(true);
        initialize( );
		
	}
	/**
     * This method initializes this
     * 
     * @return void
     */
    private void initialize( )
    {
        this.setSize(310, 236);
        this.setTitle("Agregar Cancion");
        this.setContentPane( getJContentPane( ) );
    }
    /**
     * This method initializes jContentPane
     * 
     * @return javax.swing.JPanel
     */
    private JPanel getJContentPane( )
    {
        if( jContentPane == null )
        {
            jLabelArtistaCancion = new JLabel();
            jLabelArtistaCancion.setBounds(new Rectangle(15, 105, 65, 16));
            jLabelArtistaCancion.setText("Artista :");
            jLabelDuracionCancion = new JLabel();
            jLabelDuracionCancion.setBounds(new Rectangle(15, 75, 70, 16));
            jLabelDuracionCancion.setText("Duracion :");
            jLabelGeneroCancion = new JLabel();
            jLabelGeneroCancion.setBounds(new Rectangle(15, 45, 61, 16));
            jLabelGeneroCancion.setText("Genero :");
            jLabelNombreCancion = new JLabel();
            jLabelNombreCancion.setBounds(new Rectangle(15, 15, 61, 16));
            jLabelNombreCancion.setText("Nombre :");
            jContentPane = new JPanel( );
            jContentPane.setLayout(null);
            jContentPane.add(jLabelNombreCancion, null);
            jContentPane.add(getJTextFieldNombreCancion(), null);
            jContentPane.add(jLabelGeneroCancion, null);
         
            jContentPane.add(jLabelDuracionCancion, null);
            jContentPane.add(jLabelArtistaCancion, null);
            jContentPane.add(getJTextFieldDuracionCancion(), null);
            jContentPane.add(getJTextFieldArtistaCancion(), null);
            jContentPane.add(getJButtonAgregarCancion(), null);
            jContentPane.add(getJButtonCancelar(), null);
            jContentPane.add(getJComboBoxGeneroCancion(), null);
        }
        return jContentPane;
    }
    /**
     * This method initializes jTextFieldNombreCancion	
     * 	
     * @return javax.swing.JTextField	
     */
    private JTextField getJTextFieldNombreCancion( )
    {
        if( jTextFieldNombreCancion == null )
        {
            jTextFieldNombreCancion = new JTextField( );
            jTextFieldNombreCancion.setBounds(new Rectangle(135, 15, 151, 16));
        }
        return jTextFieldNombreCancion;
    }
    
    /**
     * This method initializes jTextFieldDuracionCancion	
     * 	
     * @return javax.swing.JTextField	
     */
    private JTextField getJTextFieldDuracionCancion( )
    {
        if( jTextFieldDuracionCancion == null )
        {
            jTextFieldDuracionCancion = new JTextField( );
            jTextFieldDuracionCancion.setBounds(new Rectangle(135, 75, 151, 16));
            jTextFieldDuracionCancion.setText("minutos:segundos");
        }
        return jTextFieldDuracionCancion;
    }
    /**
     * This method initializes jTextFieldArtistaCancion	
     * 	
     * @return javax.swing.JTextField	
     */
    private JTextField getJTextFieldArtistaCancion( )
    {
        if( jTextFieldArtistaCancion == null )
        {
            jTextFieldArtistaCancion = new JTextField( );
            jTextFieldArtistaCancion.setBounds(new Rectangle(135, 105, 151, 16));
        }
        return jTextFieldArtistaCancion;
    }
    /**
     * This method initializes jButtonAgregarCancion	
     * 	
     * @return javax.swing.JButton	
     */
    private JButton getJButtonAgregarCancion( )
    {
        if( jButtonAgregarCancion == null )
        {
            jButtonAgregarCancion = new JButton( );
            jButtonAgregarCancion.setBounds(new Rectangle(30, 150, 91, 32));
            jButtonAgregarCancion.setText("Agregar");
            jButtonAgregarCancion.addActionListener(new java.awt.event.ActionListener() 
            
            {
            	public void actionPerformed(java.awt.event.ActionEvent e) 
            	{
            		String nNombre=jTextFieldNombreCancion.getText();
            		String nArtista = jTextFieldArtistaCancion.getText();
            		String nGenero= (String) jComboBoxGeneroCancion.getSelectedItem();
            		String nRuta="";
            		String nDuracion=jTextFieldDuracionCancion.getSelectedText();
					try {
						nRuta = mundo.copiar();
					} catch (IOException e2) {
						// TODO Auto-generated catch block
						e2.printStackTrace();
					}					
            		
            		try {
						mundo.agregarCancion(nNombre, nArtista, nGenero, nRuta, nDuracion);
						
					} catch (Exception e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
            	
                 	}
            });
        }
        return jButtonAgregarCancion;
    }
    /**
     * This method initializes jButtonCancelar	
     * 	
     * @return javax.swing.JButton	
     */
    private JButton getJButtonCancelar( )
    {
        if( jButtonCancelar == null )
        {
            jButtonCancelar = new JButton( );
            jButtonCancelar.setBounds(new Rectangle(180, 150, 87, 31));
            jButtonCancelar.setText("Cerrar");
            jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
            	public void actionPerformed(java.awt.event.ActionEvent e) {
            		dispose();
            		
            	}
            });
        }
        return jButtonCancelar;
    }
	/**
	 * This method initializes jComboBoxGeneroCancion	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBoxGeneroCancion() {
		if (jComboBoxGeneroCancion == null) {
			jComboBoxGeneroCancion = new JComboBox();
			jComboBoxGeneroCancion.setBounds(new Rectangle(135, 44, 151, 17));
			jComboBoxGeneroCancion.addItem("Jazz");
			jComboBoxGeneroCancion.addItem("World");
			jComboBoxGeneroCancion.addItem("Electronical & Dance");
			jComboBoxGeneroCancion.addItem("Rock");
			jComboBoxGeneroCancion.addItem("Latin");
			jComboBoxGeneroCancion.addItem("Clasica");
		}
		return jComboBoxGeneroCancion;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
